package ch.exm.storm.query.inmemory;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

import ch.exm.storm.query.AbstractQuery;
import ch.exm.storm.store.ObjectStore;

public class InMemoryQuery extends AbstractQuery {
	
	private ObjectStore objectStore;

	InMemoryQuery(ObjectStore objectStore) {
		this.objectStore = objectStore;
	}

	@Override
	protected void evaluateQueryPlan() {
		Map<Class<?>, Collection<?>> workingSet = new HashMap<Class<?>, Collection<?>>();
		for (Class<?> queriedClass : getQueriedClasses()) 
			workingSet.put(queriedClass, objectStore.getAll(queriedClass));
		queryPlan = new InMemoryQueryPlan(workingSet, selection, conditions);
	}
}
